﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace EpiMapit
{
    class Auxiliars
    {
        internal static string CutEndingZeros(string geoCode)
        {
            string pattern = "^(.*?)(0+)$";

            Regex regex = new Regex(pattern);

            Match match = regex.Match(geoCode);

            string start = match.Groups[1].Value;
            string zeros = match.Groups[2].Value;

            return start;
        }

        internal static DateTime ParseDate(string filename)
        {
            string pattern = ".*(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)";

            Regex regex = new Regex(pattern);

            Match match = regex.Match(filename);

            string str_year = match.Groups[1].Value;
            string str_month = match.Groups[2].Value;
            string str_day = match.Groups[3].Value;

            int year, day, month;

            year = int.Parse(str_year);
            day = int.Parse(str_day);
            month = int.Parse(str_month);

            return new DateTime(year, month, day);
        }
    }
}
